<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?php echo $_tpl['js']; ?>jquery.js"></script>
<script language="javascript">

	function chagecate( mid, pid )
	{
		var html = '<option value="0">顶级栏目</option>';
		var url = "get_column.php";
		$.get(url,{"module_type_id":mid},function(data)
		{
			eval("var cate="+data+";");
			for (i=0; i<cate.length ; i++ )
			{
				var space = '';
				for (j=0; j<cate[i].level ; j++ )
				{
					space += '&nbsp;&nbsp;';
				}

				if ( pid !='' && cate[i].id == pid )
				{
					html += '<option selected="selected" value="' + cate[i].id + '">' + space + cate[i].cname + '</option>';
				}
				else
				{
					html += '<option value="' + cate[i].id + '">' + space + cate[i].cname + '</option>';
				}
			}
			$("#parent_id").html( html );
		});
	}

	$(function(){
		$("#module_type_id").change( function() {
			var mid = $("#module_type_id").val();
			if ( mid == 0 )
			{
				$("#parent_id").html('<option value="0">顶级栏目</option>');
			}
			else
			{
				chagecate( mid,'' );
			}
		});
	});

	function check()
	{
		var item = document.getElementById( "cname" );

		if ( item.value == "" )
		{
			alert( "请输入栏目名称" );
			item.focus();
			return false;
		}

		var item = document.getElementById( "ename" );

		if ( item.value == "" )
		{
			alert( "请输入栏目英文名称" );
			item.focus();
			return false;
		}

		var item = document.getElementById( "module_type_id" );

		if ( item.options[item.selectedIndex].value == 0 )
		{
			alert( "请选择内容模型" );
			item.focus();
			return false;
		}

		var item = document.getElementById( "parent_id" );

		if ( item.options[item.selectedIndex].value == '' )
		{
			alert( "请选择父栏目" );
			item.focus();
			return false;
		}
		document.getElementById( "submit" ).disabled = true;
		return true;
	}

	//检查栏目英文名称是否已存在
	function checkeame()
	{
		var ename = $("#ename").val();
		var pid = $("#parent_id").val();
		var url = "cheak_column_ename.php";
		$.post(url,{"ename":ename,"pid":pid},function(data)
		{
			checkflag = true;
			data = data || "{'status':0}";
			eval("var ret="+data+";");
			if(1==ret.status)
			{
				alert( ret.msg );
				return false;
			}
			else
			{
				alert( '可以创建该栏目' );
				return true;
			}
		});
	}

	function setsuper()
	{
		var e = document.getElementsByName("superset");
		var Item_Id="";

		for( var i=0;i<e.length;i++ )
		{
			if( e[i].checked )
			{
				Item_Id=e[i].value;
				if ( Item_Id==1 )
				{
					$( "#super" ). css("display","");
				}
				else
				{
					$( "#super" ). css("display","none");
				}
			}
		}
	}
</script>
</head>
<body>
<form id="apply" method="post" onsubmit="return check()">
<input type="hidden" name="reference" value="<?php echo $reference; ?>">
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
	<tr>
		<td colspan="3" height="20" align="left" bgcolor="#000000"><span class="bold">添加栏目</span></td>
	</tr>

  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727"><font color="red">&nbsp;*</font>栏目名称：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="cname" id="cname"></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727"><font color="red">&nbsp;*</font>英文名称：</td>
   <!--<td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="ename" id="ename" onblur="return checkeame()"> </td>-->
   <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="ename" id="ename"> </td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727"><font color="red">&nbsp;*</font>内容模型：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><select id="module_type_id" name="module_type_id"><option value="0">请选择</option><?php
	if ( isset( $module_type ) && is_array( $module_type ) )
	{
		foreach ( $module_type as $index => $value )
		{
			if ( $value !='' )
			{
				if ( isset( $data['module_type_id'] ) && $index == $data['module_type_id']  )
				{
					echo '<option selected="selected" value="' . $index . '">' . $value . '</option>';
					echo '<script>chagecate( ' . $data['module_type_id'] . ',' . $data['id'] . ' );</script>';
				}
				else
				{
					echo '<option value="' . $index . '">' . $value . '</option>';
				}
			}
		}
	}
	?></select></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727"><font color="red">&nbsp;*</font>父栏目：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727">
	<select id="parent_id" name="parent_id"><option value="0">顶级栏目</option></select>&nbsp;&nbsp;<span style="cursor:pointer" onclick="return checkeame()">检查栏目是否存在</span>
	</td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727"><strong>显示高级设置：</strong></td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="radio" value="0" name="superset" checked="checked" onchange="setsuper();">否<input type="radio" value="1" name="superset" onchange="setsuper();">是</td>
  </tr>
  </table>
  <div id="super" style="display:none">
  <table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
    <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">测试机域名：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="dev_domain" id="dev_domain"><font color="red">&nbsp;&nbsp;只有顶级栏目才可设置</font></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">生产机域名：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="product_domain" id="product_domain"><font color="red">&nbsp;&nbsp;只有顶级栏目才可设置</font></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">是否是专题栏目：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="radio" value="0" name="special_flag" checked="checked">否<input type="radio" value="1" name="special_flag">是</td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">是否需要审核：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="radio" value="0" name="audit_flag" checked="checked">否<input type="radio" value="1" name="audit_flag">是</td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">状态：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="radio" value="0" name="status" checked="checked">正常<input type="radio" value="1" name="status">屏蔽</td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">SEO标题：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="seo_title" id="seo_title"> 以下参数设置将覆盖"参数列表"中的SEO定义</td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">SEO关键字：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="seo_keyword" id="seo_keyword"></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">栏目描述：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="seo_description" id="seo_description"></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">SEO作者：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="seo_author" id="seo_author"></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">SEO版权：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="seo_copyright" id="seo_copyright"></td>
  </tr>
  <tr>
    <td width="38%" height="20" align="right" bgcolor="#272727">列表数目：</td>
    <td width="62%" height="20" colspan="2" align="left" bgcolor="#272727"><input type="text" name="pagesize" id="pagesize" value="<?php echo $pagesize; ?>"></td>
  </tr>
  </table>
  </div>
  <table width="90%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tr>
    <td colspan="3" align="center" bgcolor="#000000">
		<table width="40%">
			<tr align="center">
				<td><input class="btn2" type="submit" id="submit" value="提交"></td>
				<td><input class="btn2" type="button" value="返回" onclick="window.location.href='<?php echo $reference; ?>'"></td>
			</tr>
		</table>
	</td>
  </tr>
</table>
</form>
</body>
</html>